/**
*┌──────────────────────────────────────────────────────────────┐
*│　描    述：User_login_log                                                    
*│　作    者：NetCoreCMS                                            
*│　版    本：1.0    模板代码自动生成                                                
*│　创建时间：2019-12-25 10:52:46                             
*└──────────────────────────────────────────────────────────────┘
*┌──────────────────────────────────────────────────────────────┐
*│　命名空间： NetCoreCMS.Services                                  
*│　类    名： User_login_logService                                    
*└──────────────────────────────────────────────────────────────┘
*/
using NetCoreCMS.IRepository;
using NetCoreCMS.IServices;
using NetCoreCMS.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NetCoreCMS.Services
{
    public class User_login_logService: IUser_login_logService
    {
        private readonly IUser_login_logRepository _repository;

        public User_login_logService(IUser_login_logRepository repository)
        {
            _repository = repository;
        }

        public int Add(int user_id, string user_name, string remark,string ip)
        {
            User_login_log model = new User_login_log();
            model.user_id = user_id;
            model.user_name = user_name;
            model.remark = remark;
            model.login_ip = ip;
            model.login_time = DateTime.Now;
            return (int)_repository.Insert(model);
        }

        public bool ExistsDay(string username)
        {
            return _repository.ExistsDay(username);
        }

        public User_login_log GetLastModel(string user_name)
        {
            return _repository.GetLastModel(user_name);
        }

        public List<User_login_log> GetList(int top, string strWhere, string orderBy)
        {
            return _repository.GetList(strWhere + " order by " + orderBy).Take(top).ToList();
        }
    }
}